/**
### 路由呗分割成模块，便于管理
### 权限过与细致的话建议后端返回路由
经济驾驶舱=>cockpit //被定义为主路由入口
产业画像=>indestry
精准招商=>investment
营商环境=>business
系统管理=>management
产业地图=>产业地图
**/
import Vue from 'vue'
import Router from 'vue-router'
import {getToken} from '@/utils/auth'
import {saveMenuLog} from '@/api/logs'


import login from './login'
Vue.use(Router)
let routes = [...login,];

let router = new Router({
    //    mode: 'history',
    routes
})


router.beforeEach((to, from, next) => {
    if (getToken()) { // 如果已经登录的话
        next();
    } else {
        if (to.path === '/home' || to.path === '/callback' || to.path === '/user') { // 如果是登录页面的话，直接
            next();
        } else { // 否则 跳转到登录页面
            next({
                path: '/home'
            });
        }
    }
});

router.afterEach((to, from) => {
    let noLog=to.path === '/home' || to.path === '/notfound/index'
    if (!noLog) {
        //saveMenuLog(to.name, to.path);
    }
});

export default router
